package com.speily.sl5j;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * @Auther: SPL
 * @Date: 2019-08-07 17:06
 * @Description: -Logger工厂
 */
public class LoggerFactory {

    public LoggerFactory() {

    }

    public static Logger getLogger() {

        Logger logger = null;

        //加载spi实现，文件名：com.speily.sl5j.Logger
        ServiceLoader<Logger> serviceLoader = ServiceLoader.load(Logger.class);
        Iterator<Logger> loggers = serviceLoader.iterator();
        if (loggers.hasNext()) {
            logger = loggers.next();
        }

        return logger;
    }

}
